//VideoStream

import java.io.FileInputStream;
public class VideoStream {

    FileInputStream fis; //video 文件
    int frame_nb; //当前第几帧

    //构造器
    public VideoStream(String filename) throws Exception {
        fis = new FileInputStream(filename);
        frame_nb = 0;
    }

    // getnextframe
    //返回下一帧的字节数和帧的大小
    public int getNextFrame(byte[] frame) throws Exception {
        int length = 0;
        String length_string;
        byte[] frame_length = new byte[5];

        //读当前视频帧的字节大小
        fis.read(frame_length, 0, 5);

        //将frame_length转换为整数
        length_string = new String(frame_length);
        length = Integer.parseInt(length_string);
        System.out.println(length + "字节");

        return (fis.read(frame, 0, length));
    }

    public static int getInt(byte[] b) {
        int b1 = b[4] & 0xff;
        int b2 = b[3] & 0xff;
        int b3 = b[2] & 0xff;
        int b4 = b[1] & 0xff;
        return b1 | b2 << 8 | b3 << 16 | b4 << 24;

    }
}